package com.example.demo.timu.tianyiyun;

import com.example.demo.util.ResultUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: zjq
 * @Date: create in 2023/9/5 10:09
 */
@Service
public class TikuServiceImpl implements TikuService {

    @Autowired
    private TikuRepository tikuRepository;

    @Override
    public Object like(String obj) {
        String param = '%' + obj + '%';
        List<Tiku> list = tikuRepository.getTiku(param);
        return ResultUtil.success("data", list);
    }

    @Override
    public Object deleted() {
        List<String> s = tikuRepository.findSameQuestion();
        if (CollectionUtils.isEmpty(s)) {
            return ResultUtil.success("data", "重复项已删完！");
        } else {
            tikuRepository.deletedSame();
            return ResultUtil.success();
        }
    }


}
